<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Gmode | Administrator</title>
<?php echo $this->html->loadCSS("content/gmode_admin/css/reset.css");?>
<?php echo $this->html->loadCSS("content/gmode_admin/css/style.css");?>
<?php echo $this->html->loadCSS("content/gmode_admin/css/forms.css");?>
<?php echo $this->html->loadCSS("content/gmode_admin/css/grid.css");?>
<?php echo $this->html->loadCSS("content/gmode_admin/css/messages.css");?>
<!--[if lte IE 9]>
<link rel="stylesheet" media="screen" href="css/ie.css" />
<script type="text/javascript" src="js/ie.js"></script>
<![endif]-->
<?php $this->html->loadJS("content/gmode_admin/js/jquery-1.5.1.min.js")?>
<?php $this->html->loadJS("content/gmode_admin/js/jquery.tools.min.js")?>
<?php $this->html->loadJS("content/gmode_admin/js/jquery.cookie.js")?>
<?php $this->html->loadJS("content/gmode_admin/js/jquery.flot.js")?>
<?php $this->html->loadJS("content/gmode_admin/js/jquery.validate.min.js") ?>
<?php $this->html->loadJS("content/gmode_admin/js/global.js")?>
<script type="text/javascript">
$(document).ready(function(){
    var form = $("#login").validator({ 
    	position: 'bottom left', 
    	offset: [5, 0],
    	messageClass:'form-error',
    	message: '<div><em/></div>' // em element is the arrow
    });
});
</script> 
</head>
<body class="login">
    <div class="login-box main-content">
      <header>
          <h2>Gmode administrator login</h2>
      </header>
    	<section>
    		<div class="message notice">Nhập tên đăng nhập và mật khẩu để đăng nhập hệ thống</div>
    		<?php echo $this->html->beginForm("login",array('class'=>"form"))?>
			<p>
				<?php $this->html->labelFor("username") ?>
				<?php $this->html->textboxFor("username") ?>
                <?php $this->html->labelFor("password") ?>
				<?php $this->html->passwordFor("password") ?>
                <button class="large button button-gray fr" type="submit">Đăng nhập</button>
			</p>
		<?php echo $this->html->endForm();?>
    	</section>
    </div>
    <script type="text/javascript">
    $(document).ready(function(){
		$("#login").submit(function(){
	    	data = {
	    			username: $("#username").val(),
	    			password: $("#password").val()
	            };
	    		$.ajax({
	        		data: data,
	        		type: "POST",
	        		dataType: "json",
	        		success: function(response){
	    				if(response.success)
	    				{
	    					window.location.href = response.url;
	    				}
	    				else
	    				{
	    					$(".message").removeClass("notice").addClass("error").html(response.error);
	    				}
	            	}
	        	});
	        return false;
		});
    });
    </script>
</body>
</html>